//商品属性表
(function() {
	var config = require("../_include/config");
	var db = require("../db/index");
	var md5 = require("../_include/md5");
	var helper = require("../_include/helper");
	var db_table_name = config.dbname.goodsArgsMap;
	var db_id_prefix = config.dbIdPrefix.goodsArgsMap;
	//构造函数
	var _con = function(info) {
		if (!info) {
			throwCusError("参数错误，会员卡信息不可为空");
		}
		var self = this;
		self._id = db_id_prefix + (+new Date).toString(36) + Math.random().toString(36).substr(2);

		self.bus_id = info.bus_id;

		self.info = {};
		self.setInfo(info);

		self.create_time = +new Date;

		db.insert(db_table_name, self);
		console.log("生成了一个商品属性表：", self._id);
	};

	module.exports = _con;

	//技能
	_con.prototype = require("./skill");

	//静态方法
	_con.get = function(Id) {
		var result = db.find_by_id(db_table_name, Id);
		return _con.getInstance(result);
	};
	_con.getInstance = function(result) {
		if (result) {
			result.__proto__ = _con.prototype;
		}
		return result;
	};

	_con.TYPE = {
		文字: "text",
		颜色: "color",
		图片: "image",
	};

}());